﻿ 
using SHKF.B2C.Model.Entity.WorkingCenter;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SHKF.B2C.BLL.WorkingCenter
{
    public class DataWarehousInfoBLL : WorkingCenterBLL
    {
        public DataWarehousInfoBLL(SqlSugarClient db) : base(db)
        {

        }
         
        public List<DataWarehousInfoEntity> Query(string KeyValue)
        {
            List<DataWarehousInfoEntity> list = this.db
                .Queryable<DataWarehousInfoEntity>()
                .Where(ww => ww.WarehousSN.Contains(KeyValue) || ww.WarehousName.Contains(KeyValue) ) 
                .ToList();

            return list;
        }
 
        public DataWarehousInfoEntity Save(DataWarehousInfoEntity info)
        {
            if (info.SN == 0)
            {
                info.pDate = DateTime.Now;
                info.SN = this.db
                    .Insertable<DataWarehousInfoEntity>(info)
                    .ExecuteReturnBigIdentity();
            }
            else
            {
                this.db
                    .Updateable<DataWarehousInfoEntity>(info)
                    .ExecuteCommand();
            }
            return info;
        }

        public int Delete(long SN)
        {
            int result = this.db.Deleteable<DataWarehousInfoEntity>().In(SN)
                 .ExecuteCommand();

            return result;
        }
    }
}
